package com.doushu.websocket.common.dto;

import com.doushu.websocket.common.constans.ResultCode;

public final class ResultDtoFactory {
    private ResultDtoFactory() {
    }

    public static <T> ResultDto<T> toAck(String msg){
        return toAck(msg,null);
    }

    public static <T> ResultDto<T> toAck(String msg,T data){
        ResultDto<T> dto = new ResultDto<T>();
        dto.setRet(ResultCode.ACK);
        dto.setMsg(msg);
        dto.setData(data);
        return dto;
    }

    public static <T> ResultDto<T> toNack(String msg){
        return toNack(msg,null);
    }

    public static <T> ResultDto<T> toNack(String msg,T data){
        ResultDto<T> dto = new ResultDto<T>();
        dto.setRet(ResultCode.NACK);
        dto.setMsg(msg);
        dto.setData(data);
        return dto;
    }
}
